<!DOCTYPE HTML>
<html lang="en" >
    
    <head>
        
        <meta charset="UTF-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <title>伪类选择器 | Introduction</title>
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <meta name="description" content="">
        <meta name="generator" content="GitBook 2.6.7">
        
        
        <meta name="HandheldFriendly" content="true"/>
        <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
        <meta name="apple-mobile-web-app-capable" content="yes">
        <meta name="apple-mobile-web-app-status-bar-style" content="black">
        <link rel="apple-touch-icon-precomposed" sizes="152x152" href="../../gitbook/images/apple-touch-icon-precomposed-152.png">
        <link rel="shortcut icon" href="../../gitbook/images/favicon.ico" type="image/x-icon">
        
    <link rel="stylesheet" href="../../gitbook/style.css">
    
        
        <link rel="stylesheet" href="../../gitbook/plugins/gitbook-plugin-expandable-chapters-small/expandable-chapters-small.css">
        
    
        
        <link rel="stylesheet" href="../../gitbook/plugins/gitbook-plugin-highlight/website.css">
        
    
        
        <link rel="stylesheet" href="../../gitbook/plugins/gitbook-plugin-search/search.css">
        
    
        
        <link rel="stylesheet" href="../../gitbook/plugins/gitbook-plugin-fontsettings/website.css">
        
    
    

        
    
    
    <link rel="next" href="../../First/CSS/属性选择器.html" />
    
    
    <link rel="prev" href="../../First/CSS/群组选择器.html" />
    

        
    </head>
    <body>
        
        
    <div class="book"
        data-level="2.1.6"
        data-chapter-title="伪类选择器"
        data-filepath="First/CSS/伪类选择器.md"
        data-basepath="../.."
        data-revision="Fri Sep 01 2017 15:03:43 GMT+0800 (中国标准时间)"
        data-innerlanguage="">
    

<div class="book-summary">
    <nav role="navigation">
        <ul class="summary">
            
            
            
            

            

            
    
        <li class="chapter " data-level="0" data-path="index.html">
            
                
                    <a href="../../index.html">
                
                        <i class="fa fa-check"></i>
                        
                        Introduction
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="1" data-path="First/HTML/html1.html">
            
                
                    <a href="../../First/HTML/html1.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>1.</b>
                        
                        HTML5
                    </a>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.1" data-path="First/HTML/example1.html">
            
                
                    <a href="../../First/HTML/example1.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>1.1.</b>
                        
                        列表之间的同素异性体
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="1.2" data-path="First/HTML/example2.html">
            
                
                    <a href="../../First/HTML/example2.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>1.2.</b>
                        
                        常用标签
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="1.3" data-path="First/HTML/example3.html">
            
                
                    <a href="../../First/HTML/example3.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>1.3.</b>
                        
                        a标签
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="1.4" data-path="First/HTML/example4.html">
            
                
                    <a href="../../First/HTML/example4.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>1.4.</b>
                        
                        HTML5新增加的标签
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="1.5" data-path="First/HTML/example5.html">
            
                
                    <a href="../../First/HTML/example5.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>1.5.</b>
                        
                        实体字符和文本格式化
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="1.6" data-path="First/HTML/example6.html">
            
                
                    <a href="../../First/HTML/example6.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>1.6.</b>
                        
                        table标签
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="1.7" data-path="First/HTML/example7.html">
            
                
                    <a href="../../First/HTML/example7.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>1.7.</b>
                        
                        form表单与input输入框的运用
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="1.8" data-path="First/HTML/example8.html">
            
                
                    <a href="../../First/HTML/example8.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>1.8.</b>
                        
                        块级元素与内联元素的往事
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="1.9" data-path="First/HTML/example9.html">
            
                
                    <a href="../../First/HTML/example9.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>1.9.</b>
                        
                        零碎小知识
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="1.10" data-path="First/HTML/example10.html">
            
                
                    <a href="../../First/HTML/example10.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>1.10.</b>
                        
                        图像热区与内嵌框架iframe的趣事
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="1.11" data-path="First/HTML/content.html">
            
                
                    <a href="../../First/HTML/content.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>1.11.</b>
                        
                        HTML5心得和总结
                    </a>
            
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="2" data-path="First/CSS/css1.html">
            
                
                    <a href="../../First/CSS/css1.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.</b>
                        
                        CSS3
                    </a>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="2.1" data-path="First/CSS/css.html">
            
                
                    <a href="../../First/CSS/css.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.1.</b>
                        
                        CSS选择器
                    </a>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="2.1.1" data-path="First/CSS/通配选择器.html">
            
                
                    <a href="../../First/CSS/通配选择器.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.1.1.</b>
                        
                        通配选择器
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="2.1.2" data-path="First/CSS/元素选择器.html">
            
                
                    <a href="../../First/CSS/元素选择器.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.1.2.</b>
                        
                        元素选择器
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="2.1.3" data-path="First/CSS/class选择器和id选择器.html">
            
                
                    <a href="../../First/CSS/class选择器和id选择器.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.1.3.</b>
                        
                        class选择器和id选择器
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="2.1.4" data-path="First/CSS/关系选择器.html">
            
                
                    <a href="../../First/CSS/关系选择器.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.1.4.</b>
                        
                        关系选择器
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="2.1.5" data-path="First/CSS/群组选择器.html">
            
                
                    <a href="../../First/CSS/群组选择器.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.1.5.</b>
                        
                        群组选择器
                    </a>
            
            
        </li>
    
        <li class="chapter active" data-level="2.1.6" data-path="First/CSS/伪类选择器.html">
            
                
                    <a href="../../First/CSS/伪类选择器.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.1.6.</b>
                        
                        伪类选择器
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="2.1.7" data-path="First/CSS/属性选择器.html">
            
                
                    <a href="../../First/CSS/属性选择器.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.1.7.</b>
                        
                        属性选择器
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="2.1.8" data-path="First/CSS/伪对象选择器.html">
            
                
                    <a href="../../First/CSS/伪对象选择器.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.1.8.</b>
                        
                        伪对象选择器
                    </a>
            
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="2.2" data-path="First/CSS/样式.html">
            
                
                    <a href="../../First/CSS/样式.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.2.</b>
                        
                        CSS样式分类
                    </a>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="2.2.1" data-path="First/CSS/字体样式.html">
            
                
                    <a href="../../First/CSS/字体样式.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.2.1.</b>
                        
                        字体样式
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="2.2.2" data-path="First/CSS/边框样式.html">
            
                
                    <a href="../../First/CSS/边框样式.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.2.2.</b>
                        
                        边框样式
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="2.2.3" data-path="First/CSS/背景样式.html">
            
                
                    <a href="../../First/CSS/背景样式.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.2.3.</b>
                        
                        背景样式
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="2.2.4" data-path="First/CSS/元素样式.html">
            
                
                    <a href="../../First/CSS/元素样式.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.2.4.</b>
                        
                        元素样式
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="2.2.5" data-path="First/CSS/段落样式.html">
            
                
                    <a href="../../First/CSS/段落样式.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.2.5.</b>
                        
                        段落样式
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="2.2.6" data-path="First/CSS/浮动.html">
            
                
                    <a href="../../First/CSS/浮动.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.2.6.</b>
                        
                        浮动
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="2.2.7" data-path="First/CSS/网页常见定位.html">
            
                
                    <a href="../../First/CSS/网页常见定位.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.2.7.</b>
                        
                        网页常见定位
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="2.2.8" data-path="First/CSS/盒子模型.html">
            
                
                    <a href="../../First/CSS/盒子模型.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.2.8.</b>
                        
                        盒子模型
                    </a>
            
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="2.3" data-path="First/CSS/SCSS预处理.html">
            
                
                    <a href="../../First/CSS/SCSS预处理.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.3.</b>
                        
                        sass预处理用法
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="2.4" data-path="First/CSS/animate常见用法.html">
            
                
                    <a href="../../First/CSS/animate常见用法.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.4.</b>
                        
                        animate动画
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="2.5" data-path="First/CSS/媒体查询.html">
            
                
                    <a href="../../First/CSS/媒体查询.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.5.</b>
                        
                        媒体查询
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="2.6" data-path="First/CSS/Bootstrap框架栅格化系统.html">
            
                
                    <a href="../../First/CSS/Bootstrap框架栅格化系统.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.6.</b>
                        
                        Bootstrap框架栅格化系统
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="2.7" data-path="First/CSS/flexbox弹性盒子.html">
            
                
                    <a href="../../First/CSS/flexbox弹性盒子.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.7.</b>
                        
                        flexbox弹性盒子
                    </a>
            
            
        </li>
    

            </ul>
            
        </li>
    


            
            <li class="divider"></li>
            <li>
                <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
                    Published with GitBook
                </a>
            </li>
            
        </ul>
    </nav>
</div>

    <div class="book-body">
        <div class="body-inner">
            <div class="book-header" role="navigation">
    <!-- Actions Left -->
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href="../../" >Introduction</a>
    </h1>
</div>

            <div class="page-wrapper" tabindex="-1" role="main">
                <div class="page-inner">
                
                
                    <section class="normal" id="section-">
                    
                        <h1 id="&#x4F2A;&#x7C7B;&#x9009;&#x62E9;&#x5668;">&#x4F2A;&#x7C7B;&#x9009;&#x62E9;&#x5668;</h1>
<p><strong>&#x53EF;&#x4EE5;&#x8BA4;&#x4E3A;&#x5B83;&#x662F;&#x5143;&#x7D20;&#x7684;&#x4E00;&#x79CD;&#x72B6;&#x6001;</strong></p>
<h3 id="elink">E:link</h3>
<p>  &#x8BBE;&#x7F6E;&#x8D85;&#x94FE;&#x63A5;a&#x5728;&#x672A;&#x8BBF;&#x95EE;&#x524D;&#x7684;&#x6837;&#x5F0F;(&#x6CA1;&#x88AB;&#x70B9;&#x8FC7;&#x7684;)</p>
<pre><code class="lang-css">    <span class="hljs-rule"><span class="hljs-attribute">a</span>:<span class="hljs-value">link{<span class="hljs-comment">/*&#x6CA1;&#x88AB;&#x70B9;&#x8FC7;&#x7684;*/</span>
                color:black</span></span>;
    }
</code></pre>
<pre><code class="lang-html">    <span class="hljs-tag">&lt;<span class="hljs-title">a</span> <span class="hljs-attribute">href</span>=<span class="hljs-value">&quot;http://bluej.cn&quot;</span>&gt;</span>
            &#x6211;&#x662F;&#x4E00;&#x4E2A;a
    <span class="hljs-tag">&lt;/<span class="hljs-title">a</span>&gt;</span>
</code></pre>
<h3 id="evisited">E:visited</h3>
<p>  &#x8BBE;&#x7F6E;&#x8D85;&#x94FE;&#x63A5;a&#x5728;&#x8BBF;&#x95EE;&#x8FC7;&#x540E;&#x7684;&#x6837;&#x5F0F;(&#x5DF2;&#x7ECF;&#x88AB;&#x70B9;&#x8FC7;&#x7684;)</p>
<pre><code class="lang-css">    <span class="hljs-rule"><span class="hljs-attribute">a</span>:<span class="hljs-value">visited{<span class="hljs-comment">/*&#x5DF2;&#x7ECF;&#x88AB;&#x70B9;&#x8FC7;&#x4E86;*/</span>
                color: deepskyblue</span></span>;
    }
</code></pre>
<pre><code class="lang-html">    <span class="hljs-tag">&lt;<span class="hljs-title">a</span> <span class="hljs-attribute">href</span>=<span class="hljs-value">&quot;http://bluej.cn&quot;</span>&gt;</span>
            &#x6211;&#x662F;&#x4E00;&#x4E2A;a
    <span class="hljs-tag">&lt;/<span class="hljs-title">a</span>&gt;</span>
</code></pre>
<h3 id="ehover">E:hover</h3>
<p>&#x8BBE;&#x7F6E;&#x5143;&#x7D20;&#x5728;&#x5176;&#x9F20;&#x6807;&#x60AC;&#x505C;&#x65F6;&#x7684;&#x6837;&#x5F0F;(&#x9F20;&#x6807;&#x8986;&#x76D6;&#x8EAB;&#x4E0A;&#x7684;&#x65F6;&#x5019;)</p>
<pre><code class="lang-css">    <span class="hljs-rule"><span class="hljs-attribute">a</span>:<span class="hljs-value">hover{<span class="hljs-comment">/*&#x9F20;&#x6807;&#x8986;&#x76D6;&#x8EAB;&#x4E0A;&#x7684;&#x65F6;&#x5019;*/</span>
                color: red</span></span>;
    }
</code></pre>
<pre><code class="lang-html">    <span class="hljs-tag">&lt;<span class="hljs-title">a</span> <span class="hljs-attribute">href</span>=<span class="hljs-value">&quot;http://bluej.cn&quot;</span>&gt;</span>
            &#x6211;&#x662F;&#x4E00;&#x4E2A;a
    <span class="hljs-tag">&lt;/<span class="hljs-title">a</span>&gt;</span>
</code></pre>
<h3 id="eactive">E:active</h3>
<p>&#x9F20;&#x6807;&#x5904;&#x4E8E;&#x70B9;&#x51FB;&#x4E0E;&#x91CA;&#x653E;&#x4E4B;&#x95F4;&#x65F6;&#x7684;&#x6837;&#x5F0F;(&#x9F20;&#x6807;&#x6FC0;&#x6D3B;&#x8BE5;&#x6807;&#x7B7E;&#x7684;&#x65F6;&#x5019;)</p>
<pre><code class="lang-css">    <span class="hljs-rule"><span class="hljs-attribute">a</span>:<span class="hljs-value">active{<span class="hljs-comment">/*&#x9F20;&#x6807;&#x6FC0;&#x6D3B;&#x8BE5;&#x6807;&#x7B7E;&#x7684;&#x65F6;&#x5019;*/</span>
                color: yellow</span></span>;
    }
</code></pre>
<pre><code class="lang-html">    <span class="hljs-tag">&lt;<span class="hljs-title">a</span> <span class="hljs-attribute">href</span>=<span class="hljs-value">&quot;http://bluej.cn&quot;</span>&gt;</span>
            &#x6211;&#x662F;&#x4E00;&#x4E2A;a
    <span class="hljs-tag">&lt;/<span class="hljs-title">a</span>&gt;</span>
</code></pre>
<h3 id="&#x524D;&#x56DB;&#x79CD;&#x72B6;&#x6001;&#x603B;&#x7ED3;">&#x524D;&#x56DB;&#x79CD;&#x72B6;&#x6001;&#x603B;&#x7ED3;</h3>
<blockquote>
<p>&#x8D85;&#x94FE;&#x63A5;&#x72B6;&#x6001;&#x987A;&#x5E8F;</p>
<ul>
<li>a:link</li>
<li>a:visited</li>
<li>a:hover</li>
<li>a:active</li>
<li><code>a:hover</code> &#x5FC5;&#x987B;&#x4F4D;&#x4E8E; <code>a:link</code> &#x548C; <code>a:visited</code> &#x4E4B;&#x540E;&#xFF0C;<code>a:active</code> &#x5FC5;&#x987B;&#x4F4D;&#x4E8E; <code>a:hover</code> &#x4E4B;&#x540E;</li>
<li>&#x53EF;&#x9760;&#x7684;&#x987A;&#x5E8F;&#x662F;&#xFF1A;l(link)ov(visited)e h(hover)a(active)te, &#x5373;&#x7528;&#x559C;&#x6B22;(love)&#x548C;&#x8BA8;&#x538C;(hate)&#x4E24;&#x4E2A;&#x8BCD;&#x6765;&#x6982;&#x62EC;</li>
</ul>
</blockquote>
<h3 id="efocus">E:focus</h3>
<p>&#x8BBE;&#x7F6E;&#x5143;&#x7D20;&#x5728;&#x6210;&#x4E3A;&#x8F93;&#x5165;&#x7126;&#x70B9;(&#x8BE5;&#x5143;&#x7D20;&#x7684;onfocus&#x4E8B;&#x4EF6;&#x53D1;&#x751F;)&#x65F6;&#x7684;&#x6837;&#x5F0F;</p>
<pre><code class="lang-css">    <span class="hljs-class">.input</span><span class="hljs-rules">{<span class="hljs-comment">/*&#x6CA1;&#x6709;&#x83B7;&#x5F97;&#x7126;&#x70B9;&#x65F6;&#x7684;&#x72B6;&#x6001;*/</span>
            <span class="hljs-rule"><span class="hljs-attribute">color</span>:<span class="hljs-value"> red</span></span>;
    }</span>
    <span class="hljs-rule"><span class="hljs-attribute">.input</span>:<span class="hljs-value">focus{<span class="hljs-comment">/*&#x83B7;&#x53D6;&#x7126;&#x70B9;&#x65F6;&#x7684;&#x72B6;&#x6001;*/</span>
            color: skyblue</span></span>;
    }
</code></pre>
<pre><code class="lang-html">    <span class="hljs-tag">&lt;<span class="hljs-title">input</span> <span class="hljs-attribute">type</span>=<span class="hljs-value">&quot;text&quot;</span> <span class="hljs-attribute">class</span>=<span class="hljs-value">&quot;input&quot;</span> /&gt;</span>
</code></pre>
<h3 id="enots">E:not(s)</h3>
<p>&#x5339;&#x914D;&#x4E0D;&#x542B;&#x6709;s&#x9009;&#x62E9;&#x7B26;&#x7684;&#x5143;&#x7D20;E</p>
<pre><code class="lang-css">    <span class="hljs-tag">ul</span>&gt;<span class="hljs-pseudo">:not(li)</span><span class="hljs-rules">{<span class="hljs-comment">/*&#x63A7;&#x5236;&#x975E;li&#x7684;&#x5B50;&#x5143;&#x7D20;*/</span>
                <span class="hljs-rule"><span class="hljs-attribute">font-size</span>:<span class="hljs-value"> <span class="hljs-number">30px</span></span></span>;
    }</span>
</code></pre>
<pre><code class="lang-html">    <span class="hljs-tag">&lt;<span class="hljs-title">ul</span>&gt;</span>
        <span class="hljs-tag">&lt;<span class="hljs-title">p</span>&gt;</span>sdsdsd<span class="hljs-tag">&lt;/<span class="hljs-title">p</span>&gt;</span>
        <span class="hljs-tag">&lt;<span class="hljs-title">div</span>&gt;</span>sdsdsdsd<span class="hljs-tag">&lt;/<span class="hljs-title">div</span>&gt;</span>
        <span class="hljs-tag">&lt;<span class="hljs-title">div</span>&gt;</span>sdsdsdsd<span class="hljs-tag">&lt;/<span class="hljs-title">div</span>&gt;</span>
        <span class="hljs-tag">&lt;<span class="hljs-title">div</span>&gt;</span>sdsdsdsd<span class="hljs-tag">&lt;/<span class="hljs-title">div</span>&gt;</span>
        <span class="hljs-tag">&lt;<span class="hljs-title">li</span>&gt;</span>111<span class="hljs-tag">&lt;/<span class="hljs-title">li</span>&gt;</span>
        <span class="hljs-tag">&lt;<span class="hljs-title">li</span>&gt;</span>222<span class="hljs-tag">&lt;/<span class="hljs-title">li</span>&gt;</span>
        <span class="hljs-tag">&lt;<span class="hljs-title">li</span>&gt;</span>333<span class="hljs-tag">&lt;/<span class="hljs-title">li</span>&gt;</span>
        <span class="hljs-tag">&lt;<span class="hljs-title">li</span>&gt;</span>444<span class="hljs-tag">&lt;/<span class="hljs-title">li</span>&gt;</span>
    <span class="hljs-tag">&lt;/<span class="hljs-title">ul</span>&gt;</span>
</code></pre>
<h3 id="enthchildnefirstchild">E:nth-child(n),E:first-child</h3>
<p>&#x5B50;&#x5143;&#x7D20;&#x7CFB;&#x5217;,&#x90FD;&#x662F;&#x901A;&#x8FC7;&#x5B50;&#x5143;&#x7D20;&#x7684;&#x4F4D;&#x7F6E;&#x6765;&#x63A7;&#x5236;&#x5BF9;&#x5E94;&#x7684;&#x5B50;&#x5143;&#x7D20;(&#x4E0D;&#x533A;&#x5206;&#x7C7B;&#x578B;)</p>
<pre><code class="lang-css">    <span class="hljs-tag">ul</span>&gt;<span class="hljs-rule"><span class="hljs-attribute">li</span>:<span class="hljs-value"><span class="hljs-function">nth-child</span>(<span class="hljs-number">1</span>){<span class="hljs-comment">/*ul&#x4E0B;&#x9762;&#x7684;&#x7B2C;&#x4E00;&#x4E2A;li&#x5B50;&#x5143;&#x7D20;*/</span>
                background-color: pink</span></span>;
    }
    <span class="hljs-tag">ul</span>&gt;<span class="hljs-rule"><span class="hljs-attribute">li</span>:<span class="hljs-value"><span class="hljs-function">nth-child</span>(odd){<span class="hljs-comment">/*ul&#x4E0B;&#x9762;&#x7684;&#x5947;&#x6570;&#x4F4D;&#x7F6E;&#x7684;li&#x5B50;&#x5143;&#x7D20;     2n+1*/</span>
                background-color: blue</span></span>;
    }
    <span class="hljs-tag">ul</span>&gt;<span class="hljs-rule"><span class="hljs-attribute">li</span>:<span class="hljs-value"><span class="hljs-function">nth-child</span>(even){<span class="hljs-comment">/*ul&#x4E0B;&#x9762;&#x7684;&#x5076;&#x6570;&#x4F4D;&#x7F6E;&#x7684;li&#x5B50;&#x5143;&#x7D20;   2n*/</span>
                background-color: pink</span></span>;
    }
    <span class="hljs-tag">ul</span>&gt;<span class="hljs-rule"><span class="hljs-attribute">li</span>:<span class="hljs-value">first-child,ul&gt;li:last-child{<span class="hljs-comment">/*ul&#x4E0B;&#x9762;&#x7684;&#x7B2C;&#x4E00;&#x4E2A;&#x548C;&#x6700;&#x540E;&#x4E00;&#x4E2A;li&#x5143;&#x7D20;*/</span>
                background-color: black</span></span>;
    }
    <span class="hljs-tag">ul</span>&gt;<span class="hljs-pseudo">:nth-child(3n)</span><span class="hljs-rules">{<span class="hljs-comment">/*&#x63A7;&#x5236;ul&#x4E0B;&#x9762;&#x7684;&#x6240;&#x6709;&#x5B50;&#x5143;&#x7D20;,&#x5E76;&#x4E14;&#x4F4D;&#x7F6E;&#x662F;3n&#x7684;&#x65F6;&#x5019;*/</span>
                <span class="hljs-rule"><span class="hljs-attribute">background</span>:<span class="hljs-value"> darkblue</span></span>;
    }</span>
</code></pre>
<pre><code class="lang-html">    <span class="hljs-tag">&lt;<span class="hljs-title">ul</span>&gt;</span>
        <span class="hljs-tag">&lt;<span class="hljs-title">li</span>&gt;</span>111<span class="hljs-tag">&lt;/<span class="hljs-title">li</span>&gt;</span>
        <span class="hljs-tag">&lt;<span class="hljs-title">li</span>&gt;</span>222<span class="hljs-tag">&lt;/<span class="hljs-title">li</span>&gt;</span>
        <span class="hljs-tag">&lt;<span class="hljs-title">li</span>&gt;</span>333<span class="hljs-tag">&lt;/<span class="hljs-title">li</span>&gt;</span>
        <span class="hljs-tag">&lt;<span class="hljs-title">li</span>&gt;</span>444<span class="hljs-tag">&lt;/<span class="hljs-title">li</span>&gt;</span>
    <span class="hljs-tag">&lt;/<span class="hljs-title">ul</span>&gt;</span>
</code></pre>
<blockquote>
<p>&#x6CE8;&#x610F;:</p>
<ul>
<li><code>E:first-child</code>&#x9009;&#x62E9;&#x7B26;&#xFF0C;E&#x5FC5;&#x987B;&#x662F;&#x5B83;&#x7684;&#x5144;&#x5F1F;&#x5143;&#x7D20;&#x4E2D;&#x7684;&#x7B2C;&#x4E00;&#x4E2A;&#x5143;&#x7D20;&#xFF0C;
&#x6362;&#x8A00;&#x4E4B;&#xFF0C;<strong>E&#x5FC5;&#x987B;&#x662F;&#x7236;&#x5143;&#x7D20;&#x7684;&#x7B2C;&#x4E00;&#x4E2A;&#x5B50;&#x5143;&#x7D20;</strong>,<strong>&#x5426;&#x5219;&#x9009;&#x62E9;&#x5668;&#x5931;&#x6548;</strong>&#x3002;
&#x4E0E;&#x4E4B;&#x7C7B;&#x4F3C;&#x7684;&#x4F2A;&#x7C7B;&#x8FD8;&#x6709;E:last-child&#xFF0C;&#x53EA;&#x4E0D;&#x8FC7;&#x60C5;&#x51B5;&#x6B63;&#x597D;&#x76F8;&#x53CD;&#xFF0C;&#x9700;&#x8981;&#x5B83;&#x662F;&#x6700;&#x540E;&#x4E00;&#x4E2A;&#x5B50;&#x5143;&#x7D20;&#x3002;</li>
<li><code>E:nth-child(n)</code>,<strong>&#x5339;&#x914D;&#x7236;&#x5143;&#x7D20;&#x7684;&#x7B2C;n&#x4E2A;&#x5B50;&#x5143;&#x7D20;E&#xFF0C;&#x5047;&#x8BBE;&#x8BE5;&#x5B50;&#x5143;&#x7D20;&#x4E0D;&#x662F;E&#xFF0C;&#x5219;&#x9009;&#x62E9;&#x7B26;&#x65E0;&#x6548;</strong>&#x3002;</li>
<li><code>:nth-child(n)</code>,&#x63A7;&#x5236;&#x7236;&#x5143;&#x7D20;&#x4E0B;&#x9762;&#x7684;&#x6240;&#x6709;&#x5B50;&#x5143;&#x7D20;(&#x65E0;&#x8BBA;&#x4EC0;&#x4E48;&#x6807;&#x7B7E;)&#x7684;&#x6837;&#x5F0F;.</li>
</ul>
</blockquote>
<h3 id="enthoftypenefirstoftype">E:nth-of-type(n),E:first-of-type</h3>
<p>&#x5B50;&#x7C7B;&#x578B;&#x7CFB;&#x5217;,&#x5339;&#x914D;&#x540C;&#x7C7B;&#x578B;&#x4E2D;&#x7684;&#x540C;&#x7EA7;&#x5144;&#x5F1F;&#x5143;&#x7D20;E</p>
<pre><code class="lang-css">    <span class="hljs-tag">ul</span>&gt;<span class="hljs-rule"><span class="hljs-attribute">li</span>:<span class="hljs-value">first-of-type{<span class="hljs-comment">/*&#x63A7;&#x5236;ul&#x4E0B;&#x9762;&#x7684;&#x7B2C;&#x4E00;&#x4E2A;li&#x7C7B;&#x578B;&#x7684;&#x5B50;&#x5143;&#x7D20;*/</span>
            background-color: black</span></span>;
    }
    <span class="hljs-tag">ul</span>&gt;<span class="hljs-rule"><span class="hljs-attribute">div</span>:<span class="hljs-value"><span class="hljs-function">nth-of-type</span>(odd){<span class="hljs-comment">/*&#x63A7;&#x5236;ul&#x4E0B;&#x9762;&#x7684;div&#x7C7B;&#x578B;&#x5143;&#x7D20;,&#x5E76;&#x4E14;&#x4F4D;&#x7F6E;&#x662F;&#x5728;&#x5947;&#x6570;&#x4F4D;*/</span>
            color: green</span></span>;
    }
    <span class="hljs-tag">ul</span>&gt;<span class="hljs-rule"><span class="hljs-attribute">div</span>:<span class="hljs-value"><span class="hljs-function">nth-of-type</span>(even){<span class="hljs-comment">/*&#x63A7;&#x5236;ul&#x4E0B;&#x9762;&#x7684;div&#x7C7B;&#x578B;&#x5143;&#x7D20;,&#x5E76;&#x4E14;&#x4F4D;&#x7F6E;&#x662F;&#x5728;&#x5076;&#x6570;&#x4F4D;*/</span>
            color: bisque</span></span>;
    }
    <span class="hljs-tag">ul</span>&gt;<span class="hljs-pseudo">:nth-of-type(3n)</span><span class="hljs-rules">{<span class="hljs-comment">/*&#x63A7;&#x5236;ul&#x4E0B;&#x9762;&#x7684;&#x6240;&#x6709;&#x5B50;&#x5143;&#x7D20;,&#x5E76;&#x4E14;&#x4F4D;&#x7F6E;&#x662F;3n&#x7684;&#x65F6;&#x5019;*/</span>
            <span class="hljs-rule"><span class="hljs-attribute">background</span>:<span class="hljs-value">green</span></span>;
    }</span>
</code></pre>
<pre><code class="lang-html">    <span class="hljs-tag">&lt;<span class="hljs-title">ul</span>&gt;</span>
        <span class="hljs-tag">&lt;<span class="hljs-title">p</span>&gt;</span>sdsdsd<span class="hljs-tag">&lt;/<span class="hljs-title">p</span>&gt;</span>
        <span class="hljs-tag">&lt;<span class="hljs-title">div</span>&gt;</span>sdsdsdsd<span class="hljs-tag">&lt;/<span class="hljs-title">div</span>&gt;</span>
        <span class="hljs-tag">&lt;<span class="hljs-title">div</span>&gt;</span>sdsdsdsd<span class="hljs-tag">&lt;/<span class="hljs-title">div</span>&gt;</span>
        <span class="hljs-tag">&lt;<span class="hljs-title">div</span>&gt;</span>sdsdsdsd<span class="hljs-tag">&lt;/<span class="hljs-title">div</span>&gt;</span>
        <span class="hljs-tag">&lt;<span class="hljs-title">li</span>&gt;</span>111<span class="hljs-tag">&lt;/<span class="hljs-title">li</span>&gt;</span>
        <span class="hljs-tag">&lt;<span class="hljs-title">li</span>&gt;</span>222<span class="hljs-tag">&lt;/<span class="hljs-title">li</span>&gt;</span>
        <span class="hljs-tag">&lt;<span class="hljs-title">li</span>&gt;</span>333<span class="hljs-tag">&lt;/<span class="hljs-title">li</span>&gt;</span>
        <span class="hljs-tag">&lt;<span class="hljs-title">li</span>&gt;</span>444<span class="hljs-tag">&lt;/<span class="hljs-title">li</span>&gt;</span>
    <span class="hljs-tag">&lt;/<span class="hljs-title">ul</span>&gt;</span>
</code></pre>
<blockquote>
<p>&#x6CE8;&#x610F;:</p>
<ul>
<li><code>E:first-of-type</code>&#x5339;&#x914D;&#x540C;&#x7C7B;&#x578B;&#x4E2D;&#x7684;&#x7B2C;&#x4E00;&#x4E2A;&#x540C;&#x7EA7;&#x5144;&#x5F1F;&#x5143;&#x7D20;E,
&#x4E0E;&#x4E4B;&#x7C7B;&#x4F3C;&#x7684;&#x4F2A;&#x7C7B;&#x8FD8;&#x6709;<code>E:last-of-type</code>&#xFF0C;&#x53EA;&#x4E0D;&#x8FC7;&#x60C5;&#x51B5;&#x6B63;&#x597D;&#x76F8;&#x53CD;&#xFF0C;&#x9700;&#x8981;&#x5B83;&#x662F;&#x540C;&#x7C7B;&#x578B;&#x4E2D;&#x6700;&#x540E;&#x4E00;&#x4E2A;&#x5B50;&#x5143;&#x7D20;&#x3002;</li>
<li>&#x5982;&#x679C;<code>body</code>&#x4E2D;&#x6709;&#x591A;&#x79CD;&#x540C;&#x7C7B;&#x578B;&#x7684;&#x6807;&#x7B7E;&#xFF0C;&#x90A3;<code>:first-of-type</code>&#x5C31;&#x5339;&#x914D;&#x6BCF;&#x79CD;&#x6807;&#x7B7E;&#x5728;&#x540C;&#x7C7B;&#x578B;&#x7684;&#x7B2C;&#x4E00;&#x4E2A;.</li>
<li><code>E:nth-of-type(n)</code>&#x5339;&#x914D;&#x540C;&#x7C7B;&#x578B;&#x4E2D;&#x7684;&#x7B2C;n&#x4E2A;&#x540C;&#x7EA7;&#x5144;&#x5F1F;&#x5143;&#x7D20;E</li>
<li><code>:nth-of-type(n)</code>,&#x63A7;&#x5236;&#x7236;&#x5143;&#x7D20;&#x4E0B;&#x9762;&#x7684;&#x6240;&#x6709;&#x5B50;&#x5143;&#x7D20;(&#x65E0;&#x8BBA;&#x4EC0;&#x4E48;&#x6807;&#x7B7E;)&#x7684;&#x6837;&#x5F0F;</li>
</ul>
</blockquote>
<h3 id="firstchild&#x4E0E;firstoftype&#x7684;&#x533A;&#x522B;">first-child&#x4E0E;first-of-type&#x7684;&#x533A;&#x522B;</h3>
<pre><code class="lang-css">
    <span class="hljs-comment">/* a:first-child&#x662F;.test&#x4E0B;&#x7684;&#x7B2C;&#x4E00;&#x4E2A;&#x7ED3;&#x6784;&#x6807;&#x7B7E;&#xFF0C;&#x800C;&#x4E14;&#x662F;a&#x6807;&#x7B7E;&#xFF0C;&#x4E0D;&#x662F;&#x5219;&#x4E0D;&#x8D77;&#x6548;&#x679C; */</span>

    <span class="hljs-class">.test</span> <span class="hljs-rule"><span class="hljs-attribute">a</span>:<span class="hljs-value">first-child{color:red</span></span>;}

     <span class="hljs-comment">/* a:first-of-type&#x4E0D;&#x9700;&#x8981;&#x662F;&#x7B2C;&#x4E00;&#x4E2A;&#x5B50;&#x5143;&#x7D20;,&#x53EA;&#x9700;&#x8981;.test&#x4E0B;&#x7684;a&#x6807;&#x7B7E;&#x7684;&#x7B2C;&#x4E00;&#x4E2A;&#x5373;&#x53EF; */</span>

    <span class="hljs-class">.test</span> <span class="hljs-rule"><span class="hljs-attribute">a</span>:<span class="hljs-value">first-of-type{font-size:<span class="hljs-number">55px</span></span></span>;}
</code></pre>
<pre><code class="lang-html">    <span class="hljs-tag">&lt;<span class="hljs-title">div</span> <span class="hljs-attribute">class</span>=<span class="hljs-value">&quot;test&quot;</span>&gt;</span>
   <span class="hljs-comment">&lt;!-- &lt;a href=&quot;#&quot;&gt;&#x6D4B;&#x8BD5;&lt;/a&gt; --&gt;</span>
        <span class="hljs-tag">&lt;<span class="hljs-title">p</span>&gt;</span>p&#x6807;&#x7B7E;<span class="hljs-tag">&lt;/<span class="hljs-title">p</span>&gt;</span>
        <span class="hljs-tag">&lt;<span class="hljs-title">a</span> <span class="hljs-attribute">href</span>=<span class="hljs-value">&quot;#&quot;</span>&gt;</span>a&#x6807;&#x7B7E;<span class="hljs-tag">&lt;/<span class="hljs-title">a</span>&gt;</span>
        <span class="hljs-tag">&lt;<span class="hljs-title">a</span> <span class="hljs-attribute">href</span>=<span class="hljs-value">&quot;#&quot;</span>&gt;</span>a&#x6807;&#x7B7E;<span class="hljs-tag">&lt;/<span class="hljs-title">a</span>&gt;</span>
  <span class="hljs-tag">&lt;/<span class="hljs-title">div</span>&gt;</span>
</code></pre>
<h3 id="&#x5176;&#x5B83;&#x5C5E;&#x6027;">&#x5176;&#x5B83;&#x5C5E;&#x6027;</h3>
<table>
<thead>
<tr>
<th style="text-align:center">&#x5B57;&#x7B26;&#x540D;</th>
<th style="text-align:center">&#x63CF;&#x8FF0;</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:center">E:checked</td>
<td style="text-align:center">&#x5339;&#x914D;&#x7528;&#x6237;&#x754C;&#x9762;&#x4E0A;&#x5904;&#x4E8E;&#x9009;&#x4E2D;&#x72B6;&#x6001;&#x7684;&#x5143;&#x7D20;E(&#x7528;&#x4E8E;input type&#x4E3A;radio&#x4E0E;checkbox&#x65F6;)</td>
</tr>
<tr>
<td style="text-align:center">E:enabled</td>
<td style="text-align:center">&#x5339;&#x914D;&#x7528;&#x6237;&#x754C;&#x9762;&#x4E0A;&#x5904;&#x4E8E;&#x53EF;&#x7528;&#x72B6;&#x6001;&#x7684;&#x5143;&#x7D20;E</td>
</tr>
<tr>
<td style="text-align:center">E:disabled</td>
<td style="text-align:center">&#x5339;&#x914D;&#x7528;&#x6237;&#x754C;&#x9762;&#x4E0A;&#x5904;&#x4E8E;&#x7981;&#x7528;&#x72B6;&#x6001;&#x7684;&#x5143;&#x7D20;E</td>
</tr>
<tr>
<td style="text-align:center">E:target</td>
<td style="text-align:center">&#x5339;&#x914D;&#x76F8;&#x5173;URL&#x6307;&#x5411;&#x7684;E&#x5143;&#x7D20;</td>
</tr>
</tbody>
</table>

                    
                    </section>
                
                
                </div>
            </div>
        </div>

        
        <a href="../../First/CSS/群组选择器.html" class="navigation navigation-prev " aria-label="Previous page: 群组选择器"><i class="fa fa-angle-left"></i></a>
        
        
        <a href="../../First/CSS/属性选择器.html" class="navigation navigation-next " aria-label="Next page: 属性选择器"><i class="fa fa-angle-right"></i></a>
        
    </div>
</div>

        
<script src="../../gitbook/app.js"></script>

    
    <script src="../../gitbook/plugins/gitbook-plugin-expandable-chapters-small/expandable-chapters-small.js"></script>
    

    
    <script src="../../gitbook/plugins/gitbook-plugin-search/lunr.min.js"></script>
    

    
    <script src="../../gitbook/plugins/gitbook-plugin-search/search.js"></script>
    

    
    <script src="../../gitbook/plugins/gitbook-plugin-sharing/buttons.js"></script>
    

    
    <script src="../../gitbook/plugins/gitbook-plugin-fontsettings/buttons.js"></script>
    

    
    <script src="../../gitbook/plugins/gitbook-plugin-livereload/plugin.js"></script>
    

<script>
require(["gitbook"], function(gitbook) {
    var config = {"expandable-chapters-small":{},"highlight":{},"search":{"maxIndexSize":1000000},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"fontsettings":{"theme":"white","family":"sans","size":2},"livereload":{}};
    gitbook.start(config);
});
</script>

        
    </body>
    
</html>
